using System;
using System.Collections;
using GameFramework.DataTable;
using Unity.VisualScripting;
using UnityEngine;
using UnityGameFramework.Runtime;

namespace LS.UGFUnits
{
    [UnitShortTitle("Data Table")]
    [UnitSurtitle("Get")]
    public sealed class GetDataTable : DataTableUnit
    {
        [Serialize]
        [Inspectable, UnitHeaderInspectable]
        [TypeFilter(typeof(DataRowBase))]
        public System.Type DataTableType { get; private set; }
        
        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput Data { get; private set; }

        protected override void Definition()
        {
            base.Definition();
            Data = ValueOutput<DataTableBase>(nameof(Data));
        }

        protected override ControlOutput In(Flow flow)
        {
            DataTableBase dataTable = Target?.GetDataTable(DataTableType);
            flow.SetValue(Data, dataTable);
            return base.In(flow);
        }
    }
}